Ext.define('IHC.controller.ihc.cadastros.IHC002DetailListController', { 
	extend: 'Ext.app.Controller',
	
	requires: [
		'IHC.model.Colaborador',
		'IHC.store.ihc.cadastros.IHC002Colaborador',
		'IHC.view.ihc.cadastros.IHC002DetailListView'
	],
	
	stores: [
		'IHC.store.ihc.cadastros.IHC002Colaborador'
	],
	
	models: [
		'IHC.model.Colaborador'
	],
	
	views: [
		'IHC.view.ihc.cadastros.IHC002DetailListView'
	],
	
	formModule: 'IHC.controller.ihc.cadastros',
	
	formName: 'IHC002',
	
	suffixName: 'Detail',
	
	mixins: [
		'InsoftExtUi.ux.mixins.controller.CrudDetailListMixin'
	],
	
	refs: [{ 
		selector: 'ihc002-detail-list',
		xtype: 'ihc002-detail-list',
		ref: 'mainGrid',
		autoCreate: true
	}],
	
	init: function() {
		var me = this;
		
		if(!me.inited) {
			me.bindDefaultActions('#ihc002-detail-list');
			me.bindMasterRecordEvents('#IHC.controller.ihc.cadastros.IHC002ListController');
			me.recordStore = me.getStore('IHC.store.ihc.cadastros.IHC002Colaborador');
		}
		
		me.inited = true; 
	},
	
	populateDetails : function() {
		var me = this;
		me.setDefaultFilter(me.masterRecord);
		me.recordStore.load();
	},
	
	setDefaultFilter : function(masterRecord) {
		var me = this;
		
		if (masterRecord) {
			me.recordStore.proxy.extraParams = {
				'extraFilter.equipe.id': masterRecord.get('id')
			};
		} else {
			me.recordStore.proxy.extraParams = {
				'extraFilter.equipe.id': -1
			};
		}
	},
	
	actionIndex : function() {
		var me = this,
			manager = me.getLocaleManager(),
			title = manager.get('ihc002-detail.mainPanel.title');
		
		me.setDefaultFilter(null);
		me.recordStore.load();
	}
});
